home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9443 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: solon.com!not-for-mail
  2. From: seebs@solutions.solon.com (Peter Seebach)
  3. Newsgroups: comp.sources.wanted,comp.lang.c,comp.unix.programmer
  4. Subject: Re: Seek unix2dos.c OR help with tr
  5. Date: 11 Mar 1996 06:39:47 -0600
  6. Organization: Usenet Fact Police (Undercover)
  7. Message-ID: <4i16uj$kr@solutions.solon.com>
  8. References: <4i0946$7io@nuke.csu.net> <10MAR199622434233@erich.triumf.ca>
  9. NNTP-Posting-Host: solutions.solon.com
  10.  
  11. In article <10MAR199622434233@erich.triumf.ca>,
  12. P.Bennett <bennett@erich.triumf.ca> wrote:
  13. >You should declare c as int, not char, since getchar() returns an int, and EOF
  14. >is a negative int, outside the range that can be represented by a char.
  15.  
  16. Nit: EOF may be representable as a char, if char is signed.  This is ok,
  17. since getc, fgetc, and getchar all return the next char *as an unsigned char*
  18. or EOF.
  19.  
  20. Worse, the test won't work if sizeof(int) == 1 and all char values are
  21. possible.  This is rare, but may actually happen somewhere.  (Before anyone
  22. gets confused, sizeof(char) is definitionally 1, and a machine with 16 bit
  23. or larger chars could have int and char the same size.  sizeof is not defined
  24. in terms of 8 bit bytes.)
  25.  
  26. -s
  27. -- 
  28. Peter Seebach - seebs@solon.com - Copyright 1996 Peter Seebach.
  29. C/Unix wizard -- C/Unix questions? Send mail for help.  No, really!
  30. FUCK the communications decency act.  Goddamned government.  [literally.]
  31. The *other* C FAQ - http://www.solon.com/~seebs/c/c-iaq.html
  32.